package com.lc.cehui.ui.fragment;


import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.hjq.bar.TitleBar;
import com.lc.cehui.R;
import com.lc.cehui.app.AppFragment;
import com.lc.cehui.ui.activity.ChatActivity;
import com.lc.cehui.ui.activity.MainActivity;
import com.lc.cehui.http.response.BaseBean;
import com.lc.cehui.ui.activity.land.LoginActivity;
import com.scwang.smart.refresh.header.MaterialHeader;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import io.rong.imkit.utils.RouteUtils;

public class MeassageFragment extends AppFragment<MainActivity> {
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    @BindView(R.id.refreshLayout)
    SmartRefreshLayout refreshLayout;
    private BaseQuickAdapter adapter;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_message;
    }

    @Override
    protected void initView() {
        refreshLayout.setRefreshHeader(new MaterialHeader(getContext()));
        refreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                refreshLayout.finishRefresh();
            }
        });
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        recyclerView.setAdapter(adapter = new BaseQuickAdapter<BaseBean, BaseViewHolder>(R.layout.adapter_message_item) {
            @Override
            protected void convert(@NonNull BaseViewHolder baseViewHolder, BaseBean dataBean) {

            }
        });
        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                //startActivity(ChatActivity.class);
                RouteUtils.routeToConversationListActivity(getContext(), "");
            }
        });
    }

    @Override
    protected void initData() {
        List<BaseBean> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(new BaseBean());
        }
        adapter.setNewInstance(list);
        adapter.notifyDataSetChanged();
    }
}
